﻿using OSSUtility.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ozone.Models
{
    public class KeyPoint
    {
        public class KeyPoint1
        {
            //原点位置
            public static PointXYZR OriginPosition { set; get; } = new PointXYZR(
                260, 13, 0, -270, -1
                );
            //开瓶位置
            public static PointXYZR OpenBottlePosition { set; get; } = new PointXYZR(
                202.091, -327.21, -118, -545, -1
                );
            //瓶盖位置
            public static PointXYZR CapPosition { set; get; } = new PointXYZR(
                1.3925, -192.712, -189.5, 545, -1
                );




            //瓶盖位置
            public static PointXYZR CapPosition2 { set; get; } = new PointXYZR(
                -77.6065, -192.712, -185.5, -269.9996, -1
                );


            //天平位置
            public static PointXYZR BalancePosition { set; get; } = new PointXYZR(
                -82.7563, -350.5468, -125, -270, -1
                );



            #region  配液瓶


            //配液瓶1
            public static PointXYZR SolventBottlePosition1 { set; get; } = new PointXYZR(
                336.3193, -201.2319, -202.5, -545, -1
                );

            //配液瓶2
            public static PointXYZR SolventBottlePosition2 { set; get; } = new PointXYZR(
                338.3189, -120.2293, -202.5, -270, -1
                );

            //配液瓶3
            public static PointXYZR SolventBottlePosition3 { set; get; } = new PointXYZR(
                269.3174, -157.2267, -202.5, -270, -1
                );

            //配液瓶4
            public static PointXYZR SolventBottlePosition4 { set; get; } = new PointXYZR(
                269.3163, -78.2241, -202.5, -270, -1
                );

            //配液瓶5
            public static PointXYZR SolventBottlePosition5 { set; get; } = new PointXYZR(
                201.3122, -200.2222, -202.5, -270, -1
                );

            //配液瓶6
            public static PointXYZR SolventBottlePosition6 { set; get; } = new PointXYZR(
                201.3112, -120.2281, -202.5, -270, -1
                );
            //配液瓶7
            public static PointXYZR SolventBottlePosition7 { set; get; } = new PointXYZR(
                 132.3099, -159.2207, -202.5, -270, -1
              );
            //配液瓶8
            public static PointXYZR SolventBottlePosition8 { set; get; } = new PointXYZR(
              132.3093, -80.2203, -202.5, -270, -1
            );


            #endregion

            /// <summary>
            /// 开瓶盖过度点
            /// </summary>
            public static PointXYZR OpenBottlePositionGD1 { set; get; } = new PointXYZR(
            120, -186, -10, -545, -1
            );

            //复位过度点1
            public static PointXYZR OriginPositionGD1 { set; get; } = new PointXYZR(
                100, -150, -10, -270, -1
                );




            #region 配液瓶放置位

            /// <summary>
            /// 配液瓶放置位置1 磁力搅拌上面
            /// </summary>
            public static PointXYZR SolventBottlePositionLay1 { set; get; } = new PointXYZR(
               182.9985, 368.9995, -136, -270, 1
               );

            //配液瓶放置位置2 
            public static PointXYZR SolventBottlePositionLay2 { set; get; } = new PointXYZR(
               -116.0021, 365.9976, -136, -270, 1
                );

            #endregion
        }

        /// <summary>
        /// 工作台2
        /// </summary>
        public class KeyPoint2
        {
            //扫码位置
            public static PointXYZR ScanCodePosition { set; get; } = new PointXYZR(
                82.5796, 128.4292, -84.0052, -270, 1
                );
            //开瓶位置
            public static PointXYZR OpenBottlePosition { set; get; } = new PointXYZR(
                 202.091, -327.21, -118, -545, -1
                );

            public static PointXYZR OpenBottlePositionBy10ML { set; get; } = new PointXYZR(
             258.0897, -328.2096, -158, -545, -1
             );
            //瓶盖位置
            public static PointXYZR CapPosition { set; get; } = new PointXYZR(
                -77.8983, -193.2273, -191.5050, -270, -1
                );


            #region  250ml原料瓶子

            //原液瓶1
            public static PointXYZR StockBottlePosition1 { set; get; } = new PointXYZR(
                343.3234, 26.7742, -200, -270, 1
                );
            //原液瓶2
            public static PointXYZR StockBottlePosition2 { set; get; } = new PointXYZR(
                343.323, 104.7715, -200, -270, 1
                );
            //原液瓶3
            public static PointXYZR StockBottlePosition3 { set; get; } = new PointXYZR(
                276.322, 65.7641, -200, -270, 1
                );
            //原液瓶4
            public static PointXYZR StockBottlePosition4 { set; get; } = new PointXYZR(
                272.3216, 144.7655, -200, -270, 1
                );
            #endregion




            #region  10ml原料瓶子
            //10ml位置1   Coord:  X:123.2853mm Y:11.9632mm Z:-222mm R:-360°Hand:R 
            public static PointXYZR StockBottlePosition5 { set; get; } = new PointXYZR(
                125.2849, 11.9622, -212, -360, 1
                );
            //10ml位置2 
            public static PointXYZR StockBottlePosition6 { set; get; } = new PointXYZR(
                126.285, 60.961, -212, -360, 1
                );
            //10ml位置3 
            public static PointXYZR StockBottlePosition7 { set; get; } = new PointXYZR(
                126.2851, 110.9586, -212, -360, 1
                );
            //10ml位置4 
            public static PointXYZR StockBottlePosition8 { set; get; } = new PointXYZR(
                126.2852, 161.9574, -212, -360, 1
                );
            #endregion





            #region  配液瓶终点位置 配好液体放置位置

            #endregion
            //配液瓶1终点位置
            public static PointXYZR SolventBottleEndPosition1 { set; get; } = new PointXYZR(
                -202.3065, 363.0531, -120, -180, 1
                );

            //配液瓶2终点位置
            public static PointXYZR SolventBottleEndPosition2 { set; get; } = new PointXYZR(
                -104.6928, 365.0532, -120, -180, 1
                );





            //换手过度位置1
            public static PointXYZR ChangehandsGDPosition { set; get; } = new PointXYZR(
            230, 110, -20, -270, 1
               );



            //换手过度位置2
            public static PointXYZR ChangehandsGDPosition2 { set; get; } = new PointXYZR(
            139.9975, 219.9985, -20, -270, 1
               );

            /// <summary>
            /// 换手位置
            /// </summary>
            public static PointXYZR ChangehandsPosition { set; get; } = new PointXYZR(
            230, 110, -20, -270, -1
            );
        }
        /// <summary>
        /// 点位坐标
        /// </summary>
        public class PointXYZR
        {

            public PointXYZR(double x, double y, double z, double r, int lr)
            {
                X = x;
                Y = y;
                Z = z;
                R = r;
                Lr = lr;
            }
            public double X { get; set; }
            public double Y { get; set; }
            public double Z { get; set; }
            public double R { get; set; }

            //1 右手系，-1 左手系，angle2>0 右手系，否则为左手系
            public int Lr { get; set; }
            /// <summary>
            /// 深拷贝
            /// </summary>
            /// <returns></returns>
            public PointXYZR DeeoClone()
            {
                return new PointXYZR(X, Y, Z, R, Lr);
            }
        }



        /// <summary>
        /// 液枪机械臂点位信息
        /// </summary>
        public class LiquidGunKeyPoint
        {

            //左 -1
            //右 1

            //原点位置
            public static PointXYZR OriginPosition { set; get; } = new PointXYZR(
                -153.92, -196.753, 0, 130, -1
                );

            //换手位置
            public static PointXYZR ChangehandsPosition { set; get; } = new PointXYZR(
                206, -1.68, -2, 228, 1
                );

            //吸液位置
            public static PointXYZR AbsorbLiquidPosition { set; get; } = new PointXYZR(
                168.0986, -127.6462, 0, 100, -1
                );


            /// <summary>
            /// 吐废液位置
            /// </summary>
            public static PointXYZR ToFeiYAbsorbLiquidPosition { set; get; } = new PointXYZR(
              162.0962, -166.645, 0, 218, -1
              );

            //10ML原料吸液位置
            public static PointXYZR AbsorbLiquidPositionBy10ML { set; get; } = new PointXYZR(
             168.0986, -183.6462, 0, 100, -1
            );

            //吐液位置(液枪吐液位置)
            public static PointXYZR OutLiquidPosition { set; get; } = new PointXYZR(
                124.4186, 87.5575, 0, 384.8138, 1
                );

            //吐Tip位置
            public static PointXYZR OutTipPosition { set; get; } = new PointXYZR(
                -108.9261, -196.7519, -100, 55, -1
                );


            //溶剂吐液位置(旁边小管)  下降 -150即可
            public static PointXYZR OutDiluteLiquidPosition { set; get; } = new PointXYZR(
                133.4165, 69.5554, 0, 328.8138, 1
                );

            //清洗位置
            public static PointXYZR CleanPosition { set; get; } = new PointXYZR(
                204.8520, 187.7090, -163.3630, 182.7580, 1
                );

            #region  有两版吸头
            //吸头1位置
            public static PointXYZR Tip1Position { set; get; } = new PointXYZR(
                0, 0, -176.000, 94, -1
                );
            #endregion

        }
        /// <summary>
        /// 离心工位位置坐标
        /// </summary>
        public class LiXinKeyPoint
        {
            //复位位置
            //注意 关节角度很重要
            //关节角度 1.05922,-29.5894,-118.326,0.913293,-90.7911,-180.238
            public static PointXYZ poReset { set; get; }

                = new PointXYZ(190.941, 143.519, 565.46, -179.409, -0.47, 1.3365);

            /// <summary>
            /// 三工位横抓放离心管位置
            /// </summary>
            public static PointXYZ PoPutTube { set; get; }

               = new PointXYZ(-149.262, 211.732, 474.254, -134.657, 0.932387, 39.3953);


            /// <summary>
            /// 夹爪瓶盖放置点位
            /// </summary>
            public static PointXYZ PoPutTubeEmit { set; get; }

              = new PointXYZ(-130.484, 227.664, 469.201, -135.737, -3.25864, 91.3205);

            //
            //-130.484,227.514



            /// <summary>
            /// 三工位横抓取离心管位置
            /// </summary>
            public static PointXYZ PoGetTubeToCentrifuge { set; get; }

               = new PointXYZ(-138.356, 267.545, 470.296, -139.031, -2.66177, 92.1503);
            //无盖
            public static PointXYZ PoGetTubeThreeStation { set; get; }
               = new PointXYZ(-128.357, 269.634, 454.064, -136.031, -2.66199, 92.1497);


            /// <summary>
            /// 插入离心机离心管位置 
            /// 注意这个点位是以  Tool2取执行
            /// tool的值如下 
            /// X -1.69
            /// Y 29.39
            /// Z 160.85
            /// A  133.48
            /// B  4.48
            /// C  6.81
            /// </summary>
            public static PointXYZ PoPutTubeToCentrifuge { set; get; } = new PointXYZ(24.509, -415.014, 295.868, -47.430, -3.721, -6.571);
            //public static PointXYZ PoPutTubeToCentrifuge { set; get; } = new PointXYZ(26.699, -400.203, 311.388, -47.404, -3.710, -6.575);

            /// <summary>
            /// 夹住离心管帽把它拔出来
            /// </summary>
            public static PointXYZ PoGetCentrifugeTubePo { set; get; } = new PointXYZ(22.715, -439.476, 267.150, -47.362, -3.719, -6.589);

            /// <summary>
            /// 夹住离心管帽把它拔出来
            /// </summary>
            public static PointXYZ PoGetCentrifugeTubeZAdd { set; get; } = new PointXYZ(25.894, -381.659, 320.602, -47.4177, -3.71949, -6.57491);
            //夹瓶盖位置
            public static PointXYZ jiapinggai { set; get; } = new PointXYZ(154.586, 263.853, 125.961, -135.740, -1.665, -1.323);
            public static PointXYZ fangpinggai { set; get; } = new PointXYZ(20.279, 401.150, 242.805, -131.259, -1.791, 94.791);
            public static PointXYZ fangshiguan { set; get; } = new PointXYZ(21.011, 435.274, 239.957, -131.522, -1.218, 90.960);

            //取试管瓶放入三工位横爪点位
            public static PointXYZ PutTubePos { set; get; } = new PointXYZ(-149.262, 215.732, 474.254, -134.657, 0.932387, 39.3953);


            //离心机插管
            //取插管位置
            //Z高点576.391
            public static PointXYZ InsertPipePosA { set; get; } = new PointXYZ(197.011, 74.099, 493.492, 138.821, -8.021, 18.772);

            public static PointXYZ InsertPipePosB { set; get; } = new PointXYZ(64.689, 224.845, 350, 136.192, 0.328, 67.377);

            //62.189, 224.377
            public static PointXYZ InsertPipePos { set; get; } = new PointXYZ(65.6888, 225.845, 295.539, 136.192, 1.82765, 67.3769);
            //插管放入位置
            //Z高点576.391
            public static PointXYZ InsertPipePosPut { set; get; } = new PointXYZ(119.753, 115.455, 396.074, 135.379, 1.173, 78.368);
        }
    }
    /// <summary>
    /// 旋蒸点位信息
    /// </summary>
    public class XuanZhengKeyPoint
    {
        //复位位置
        public static PointXYZ poReset { set; get; }

            = new PointXYZ(124.481, 293.199, 459.767, -175.761, -2.424, -178.346);

        #region 取瓶途径点位
        public static PointXYZ poGetA1 { set; get; } = new PointXYZ(325.299, -113.479, 474.475, -175.761, -2.424, -178.346);
        public static PointXYZ poGetA { set; get; } = new PointXYZ(238.850, -341.656, 459.767, -175.761, -2.424, -178.346);
        public static PointXYZ poGetB { set; get; } = new PointXYZ(238.850, -341.656, 713.203, 176.263, 27.654, 88.694);
        public static PointXYZ poGetC { set; get; } = new PointXYZ(45.138, -376.735, 678.681, 178.014, 25.169, 89.836);
        #endregion

        //去取瓶点位End/装瓶的终点
        public static PointXYZ poGetD { set; get; } = new PointXYZ(46.551, -428.490, 617.378, 178.266, 28.001, 89.840);
        //开始装点位/取下的点位
        public static PointXYZ poPutPos { set; get; } = new PointXYZ(46.640, -393.518, 598.759, 178.268, 27.998, 89.840);


        #region 取后放瓶途径点位
        public static PointXYZ poLayDownPos1 { set; get; } = new PointXYZ(96.959, -278.339, 586.731, -179.633, 27.055, 89.031);
        public static PointXYZ poLayDownPos2 { set; get; } = new PointXYZ(316.342, -204.652, 519.132, -126.480, 84.108, 109.104);
        public static PointXYZ poLayDownPos3A { set; get; } = new PointXYZ(86.254, 435.288, 448.100, -165.049, 87.645, 147.562);
        public static PointXYZ poLayDownPos3B { set; get; } = new PointXYZ(86.254, 435.288, 252.293, -165.049, 87.645, 147.562);

        public static PointXYZ poLayDownPos3 { set; get; } = new PointXYZ(58.569, 492.456, 272.293, -168.560, 88.056, 151.179);
        public static PointXYZ poLayDownPosEnd { set; get; } = new PointXYZ(134.408, 534.178, 198, -168.984, 88.051, 150.757);


        #endregion
        #region 插管
        //取管位置
        //Z提高500.484
        public static PointXYZ poInsertPos { set; get; } = new PointXYZ(275.186, -127.023, 339.343, -179.584, -0.962, -88.840);
        //插管的位置
        //Z低:332.725，Z高点479.323
        public static PointXYZ poInsertPosBat { set; get; } = new PointXYZ(341.046, -67.853, 332.725, -179.272, -0.089, -94.283);
        #endregion
    }

}
